/**
 * Created by zjf on 2017/2/21.
 */

//hero detail
var PropertyDetailLayer = cc.Layer.extend({
    bg:null,
    ctor:function (args) {
        this._super();

        this.initUI(args);


        //return btn，
        setTimeout(function () {
            cc.director.popScene();
        }, 5000);

    },
    initUI:function(jsonText){
        var json = JSON.parse(jsonText);
        if(json.type==0){
            //basic property fiveElement is basic property
            var hero = new Hero(json);
            hero.mySprite.setFlippedX(true);

            this.addChild(hero.mySprite);
            hero.nameText = new cc.MenuItemFont("name:"+hero.name);
            hero.nameText.x = 100;
            hero.nameText.y = hero.mySprite.y-100;
            this.addChild(hero.nameText);
            hero.hpText = new cc.MenuItemFont("hp:"+hero.hp);
            hero.hpText.x = 100;
            hero.hpText.y = hero.mySprite.y-130;
            this.addChild(hero.hpText);
            hero.levelText = new cc.MenuItemFont("level:"+hero.level);
            hero.levelText.x = 100;
            hero.levelText.y = hero.mySprite.y-160;
            this.addChild(hero.levelText);
            hero.expText = new cc.MenuItemFont("exp:"+hero.exp);
            hero.expText.x = 100;
            hero.expText.y = hero.mySprite.y-190;
            this.addChild(hero.expText);

            //detail property（hpGrow，attackGrow，defenseGrow，critical，dodge）



            //hero life brief





        }else{
            var enemy = new Enemy(json);

            this.addChild(enemy.mySprite);
            enemy.nameText = new cc.MenuItemFont("name:"+enemy.name);
            enemy.nameText.x = enemy.mySprite.x;
            enemy.nameText.y = enemy.mySprite.y-100;
            this.addChild(enemy.nameText);
            enemy.hpText = new cc.MenuItemFont("hp:"+enemy.hp);
            enemy.hpText.x = enemy.mySprite.x;
            enemy.hpText.y = enemy.mySprite.y-130;
            this.addChild(enemy.hpText);
            enemy.levelText = new cc.MenuItemFont("level:"+enemy.level);
            enemy.levelText.x = enemy.mySprite.x;
            enemy.levelText.y = enemy.mySprite.y-160;
            this.addChild(enemy.levelText);
        }

    }

});

var PropertyDetailScene = cc.Scene.extend({
    ctor:function (args) {
        this._super();
        this.args = args;
    },
    onEnter:function () {
        this._super();
        var layer = new PropertyDetailLayer(this.args);
        this.addChild(layer);
    }
});